package com.dq.Week2.day06.homeWork;

import java.util.Random;

public class Warrior extends Hero{

    private int dander;
    public Warrior(){
        super();
    }

    public Warrior(String name, int strong, int intelligence, int speed, int dander) {
        super(name, strong, intelligence, speed);
        this.dander = dander;
    }

    @Override
    public void generalCombat()//普通攻击
    {
        Random random = new Random();
        int attackPowerMAX = (int)(getStrong()*(1+0.2*1));//最大攻击力
        int attackPowerMIN = (int)(getStrong()*(1-0.2*1));//最小攻击力
        setAttackPower(random.nextInt(attackPowerMAX-attackPowerMIN)+attackPowerMIN);
        this.dander +=5;//每普通攻击一下加5怒气
        if(this.dander>500)
        {
            this.dander = 500;
        }
        System.out.println(getName()+"使用了普通攻击，攻击力为："+getAttackPower()+"\t怒气值："+this.dander);


    }


    public void heroicStrike(){
        Random random = new Random();
        int attackPowerMAX = (int)(getStrong()*(1+0.2*2));
        int attackPowerMIN = (int)(getStrong()*(1-0.2*2));
        setAttackPower(random.nextInt(attackPowerMAX-attackPowerMIN)+attackPowerMIN);
        this.dander = this.dander - 20;
        if(this.dander <= 19)
        {
            System.out.println("怒气值不足");
            return;
        }
        System.out.println(getName()+"使用了英勇打击，攻击力为："+getAttackPower()+"\t怒气值："+getDander());
    }


    @Override
    public String toString() {
        return "Warrior{" +
                "name='" + getName() + '\'' +
                ", strong=" + getStrong() +
                ", intelligence=" + getIntelligence() +
                ", speed=" + getSpeed() +
                ", attackPower=" + getAttackPower()+
                ",dander=" + dander +
                "} ";
    }

    public int getDander() {
        return dander;
    }

    public void setDander(int dander) {
        this.dander = dander;
    }
}
